﻿using CatUtils.Utils.Currency;
using CatUtils.Utils.Currency.IoUtils;
using CatUtils.Utils.Currency.TextUtils;
using CatUtils.Utils.Helper;
using RabbitDownload.Helper;

using System;
using System.Windows.Forms;

namespace RabbitDownload.ViewcCntrol
{
    internal class ViewMemoryHelper
    {
        public static String ViewStatusPath = StaticValue.BinPath + "ViewStatusPath\\";

        /// <summary>
        /// 是否下载链接转为列表
        /// </summary>
        public static string DownloadList = "DownloadList";

        /// <summary>
        /// 是否自动处理提示
        /// </summary>
        public static string DownloadAuto = "DownloadAuto";

        /// <summary>
        /// 初始化选择控件
        /// </summary>
        /// <param name="CheckBoxName"></param>
        /// <param name="checkBox"></param>
        public void InItCheckBox(string CheckBoxName, CheckBox checkBox)
        {
            string StatusText = FileHelper.ReadAllText(InitCheckFileName(CheckBoxName));
            int Status = TextHelper.StringToInt(StatusText);
            if (Status == 1)
                checkBox.Checked = true;
            if (Status == 2)
                checkBox.Checked = false;
        }

        /// <summary>
        /// 初始化选择文件名字
        /// </summary>
        /// <param name="CheckBoxName"></param>
        /// <returns></returns>
        private string InitCheckFileName(string CheckBoxName)
        {
            return string.Format(ViewStatusPath + CheckBoxName + ".txt");
        }

        /// <summary>
        /// 选项发生更改
        /// </summary>
        /// <param name="CheckBoxName"></param>
        /// <param name="checkBox"></param>
        public void CheckBoxChanged(string CheckBoxName, CheckBox checkBox)
        {
            if (checkBox.Checked) { FileHelper.WriteText(InitCheckFileName(CheckBoxName), "1"); }
            else FileHelper.WriteText(InitCheckFileName(CheckBoxName), "2");
        }
    }
}